package net.asg.games.yokeltowers.view;

import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.MathUtils;

import net.asg.games.yokeltowers.images.ImageProvider;
import net.asg.games.yokeltowers.sounds.SoundManager;
import net.asg.games.yokeltowers.view.BlockYokelGameObject.BlockType;

public class YokelGameObjectFactory {

	private ImageProvider imageProvider;
	private SoundManager soundManager;
	public boolean isHitboxActive = false;

	public YokelGameObjectFactory(ImageProvider imageProvider, SoundManager soundManager){
		this.imageProvider = imageProvider;
		this.soundManager = soundManager;
	}

	public BlockYokelGameObject getBashBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockBash();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.BASH_BLOCK);
	}
	public BlockYokelGameObject getEBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockE();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.E_BLOCK);
	}
	public BlockYokelGameObject getKBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockK();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.K_BLOCK);
	}
	public BlockYokelGameObject getLBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockL();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.L_BLOCK);
	}
	public BlockYokelGameObject getOBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockO();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.O_BLOCK);
	}
	public BlockYokelGameObject getYBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockY();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.Y_BLOCK);
	}

	public BlockYokelGameObject getClearBlock() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockClear();

		return new BlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				false, BlockYokelGameObject.BlockType.CLEAR_BLOCK);
	}

	public BrokenBlockYokelGameObject getBrokenBashBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getBrokenBlockBash(1);
		textureRegions[1] = imageProvider.getBrokenBlockBash(2);
		textureRegions[2] = imageProvider.getBrokenBlockBash(3);
		textureRegions[3] = imageProvider.getBrokenBlockBash(4);
		textureRegions[4] = imageProvider.getBrokenBlockBash(5);
		textureRegions[5] = imageProvider.getBrokenBlockBash(6);
		textureRegions[6] = imageProvider.getBrokenBlockBash(7);
		textureRegions[7] = imageProvider.getBrokenBlockBash(8);
		textureRegions[8] = imageProvider.getBrokenBlockBash(9);
		textureRegions[9] = imageProvider.getBrokenBlockBash(10);
		return new BrokenBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.BASH_BLOCK);
	}
	public BrokenBlockYokelGameObject getBrokenEBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getBrokenBlockE(1);
		textureRegions[1] = imageProvider.getBrokenBlockE(2);
		textureRegions[2] = imageProvider.getBrokenBlockE(3);
		textureRegions[3] = imageProvider.getBrokenBlockE(4);
		textureRegions[4] = imageProvider.getBrokenBlockE(5);
		textureRegions[5] = imageProvider.getBrokenBlockE(6);
		textureRegions[6] = imageProvider.getBrokenBlockE(7);
		textureRegions[7] = imageProvider.getBrokenBlockE(8);
		textureRegions[8] = imageProvider.getBrokenBlockE(9);
		textureRegions[9] = imageProvider.getBrokenBlockE(10);

		return new BrokenBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.E_BLOCK);
	}
	public BrokenBlockYokelGameObject getBrokenKBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getBrokenBlockK(1);
		textureRegions[1] = imageProvider.getBrokenBlockK(2);
		textureRegions[2] = imageProvider.getBrokenBlockK(3);
		textureRegions[3] = imageProvider.getBrokenBlockK(4);
		textureRegions[4] = imageProvider.getBrokenBlockK(5);
		textureRegions[5] = imageProvider.getBrokenBlockK(6);
		textureRegions[6] = imageProvider.getBrokenBlockK(7);
		textureRegions[7] = imageProvider.getBrokenBlockK(8);
		textureRegions[8] = imageProvider.getBrokenBlockK(9);
		textureRegions[9] = imageProvider.getBrokenBlockK(10);

		return new BrokenBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.K_BLOCK);
	}
	public BrokenBlockYokelGameObject getBrokenLBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getBrokenBlockL(1);
		textureRegions[1] = imageProvider.getBrokenBlockL(2);
		textureRegions[2] = imageProvider.getBrokenBlockL(3);
		textureRegions[3] = imageProvider.getBrokenBlockL(4);
		textureRegions[4] = imageProvider.getBrokenBlockL(5);
		textureRegions[5] = imageProvider.getBrokenBlockL(6);
		textureRegions[6] = imageProvider.getBrokenBlockL(7);
		textureRegions[7] = imageProvider.getBrokenBlockL(8);
		textureRegions[8] = imageProvider.getBrokenBlockL(9);
		textureRegions[9] = imageProvider.getBrokenBlockL(10);

		return new BrokenBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.L_BLOCK);
	}
	
	public BrokenBlockYokelGameObject getBrokenOBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getBrokenBlockO(1);
		textureRegions[1] = imageProvider.getBrokenBlockO(2);
		textureRegions[2] = imageProvider.getBrokenBlockO(3);
		textureRegions[3] = imageProvider.getBrokenBlockO(4);
		textureRegions[4] = imageProvider.getBrokenBlockO(5);
		textureRegions[5] = imageProvider.getBrokenBlockO(6);
		textureRegions[6] = imageProvider.getBrokenBlockO(7);
		textureRegions[7] = imageProvider.getBrokenBlockO(8);
		textureRegions[8] = imageProvider.getBrokenBlockO(9);
		textureRegions[9] = imageProvider.getBrokenBlockO(10);

		return new BrokenBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.O_BLOCK);
	}

	public BrokenBlockYokelGameObject getBrokenYBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getBrokenBlockY(1);
		textureRegions[1] = imageProvider.getBrokenBlockY(2);
		textureRegions[2] = imageProvider.getBrokenBlockY(3);
		textureRegions[3] = imageProvider.getBrokenBlockY(4);
		textureRegions[4] = imageProvider.getBrokenBlockY(5);
		textureRegions[5] = imageProvider.getBrokenBlockY(6);
		textureRegions[6] = imageProvider.getBrokenBlockY(7);
		textureRegions[7] = imageProvider.getBrokenBlockY(8);
		textureRegions[8] = imageProvider.getBrokenBlockY(9);
		textureRegions[9] = imageProvider.getBrokenBlockY(10);

		return new BrokenBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.Y_BLOCK);
	}
	
	public DefensiveBlockYokelGameObject getDefensiveBashBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getDefensiveBlockBash(1);
		textureRegions[1] = imageProvider.getDefensiveBlockBash(2);
		textureRegions[2] = imageProvider.getDefensiveBlockBash(3);
		textureRegions[3] = imageProvider.getDefensiveBlockBash(4);
		textureRegions[4] = imageProvider.getDefensiveBlockBash(5);
		textureRegions[5] = imageProvider.getDefensiveBlockBash(6);
		textureRegions[6] = imageProvider.getDefensiveBlockBash(7);
		textureRegions[7] = imageProvider.getDefensiveBlockBash(8);
		textureRegions[8] = imageProvider.getDefensiveBlockBash(9);
		textureRegions[9] = imageProvider.getDefensiveBlockBash(10);
		return new DefensiveBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.BASH_BLOCK);
	}
	public DefensiveBlockYokelGameObject getDefensiveEBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getDefensiveBlockE(1);
		textureRegions[1] = imageProvider.getDefensiveBlockE(2);
		textureRegions[2] = imageProvider.getDefensiveBlockE(3);
		textureRegions[3] = imageProvider.getDefensiveBlockE(4);
		textureRegions[4] = imageProvider.getDefensiveBlockE(5);
		textureRegions[5] = imageProvider.getDefensiveBlockE(6);
		textureRegions[6] = imageProvider.getDefensiveBlockE(7);
		textureRegions[7] = imageProvider.getDefensiveBlockE(8);
		textureRegions[8] = imageProvider.getDefensiveBlockE(9);
		textureRegions[9] = imageProvider.getDefensiveBlockE(10);

		return new DefensiveBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.E_BLOCK);
	}
	public DefensiveBlockYokelGameObject getDefensiveKBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getDefensiveBlockK(1);
		textureRegions[1] = imageProvider.getDefensiveBlockK(2);
		textureRegions[2] = imageProvider.getDefensiveBlockK(3);
		textureRegions[3] = imageProvider.getDefensiveBlockK(4);
		textureRegions[4] = imageProvider.getDefensiveBlockK(5);
		textureRegions[5] = imageProvider.getDefensiveBlockK(6);
		textureRegions[6] = imageProvider.getDefensiveBlockK(7);
		textureRegions[7] = imageProvider.getDefensiveBlockK(8);
		textureRegions[8] = imageProvider.getDefensiveBlockK(9);
		textureRegions[9] = imageProvider.getDefensiveBlockK(10);

		return new DefensiveBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.K_BLOCK);
	}
	public DefensiveBlockYokelGameObject getDefensiveLBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getDefensiveBlockL(1);
		textureRegions[1] = imageProvider.getDefensiveBlockL(2);
		textureRegions[2] = imageProvider.getDefensiveBlockL(3);
		textureRegions[3] = imageProvider.getDefensiveBlockL(4);
		textureRegions[4] = imageProvider.getDefensiveBlockL(5);
		textureRegions[5] = imageProvider.getDefensiveBlockL(6);
		textureRegions[6] = imageProvider.getDefensiveBlockL(7);
		textureRegions[7] = imageProvider.getDefensiveBlockL(8);
		textureRegions[8] = imageProvider.getDefensiveBlockL(9);
		textureRegions[9] = imageProvider.getDefensiveBlockL(10);

		return new DefensiveBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.L_BLOCK);
	}
	
	public DefensiveBlockYokelGameObject getDefensiveOBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getDefensiveBlockO(1);
		textureRegions[1] = imageProvider.getDefensiveBlockO(2);
		textureRegions[2] = imageProvider.getDefensiveBlockO(3);
		textureRegions[3] = imageProvider.getDefensiveBlockO(4);
		textureRegions[4] = imageProvider.getDefensiveBlockO(5);
		textureRegions[5] = imageProvider.getDefensiveBlockO(6);
		textureRegions[6] = imageProvider.getDefensiveBlockO(7);
		textureRegions[7] = imageProvider.getDefensiveBlockO(8);
		textureRegions[8] = imageProvider.getDefensiveBlockO(9);
		textureRegions[9] = imageProvider.getDefensiveBlockO(10);

		return new DefensiveBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.O_BLOCK);
	}

	public DefensiveBlockYokelGameObject getDefensiveYBlock() {
		TextureRegion [] textureRegions = new TextureRegion[10];
		textureRegions[0] = imageProvider.getDefensiveBlockY(1);
		textureRegions[1] = imageProvider.getDefensiveBlockY(2);
		textureRegions[2] = imageProvider.getDefensiveBlockY(3);
		textureRegions[3] = imageProvider.getDefensiveBlockY(4);
		textureRegions[4] = imageProvider.getDefensiveBlockY(5);
		textureRegions[5] = imageProvider.getDefensiveBlockY(6);
		textureRegions[6] = imageProvider.getDefensiveBlockY(7);
		textureRegions[7] = imageProvider.getDefensiveBlockY(8);
		textureRegions[8] = imageProvider.getDefensiveBlockY(9);
		textureRegions[9] = imageProvider.getDefensiveBlockY(10);

		return new DefensiveBlockYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive, BlockYokelGameObject.BlockType.Y_BLOCK);
	}

	public ColumnYokelGameObject getColumn() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockClear();
		textureRegions[0] = imageProvider.getDefensiveBlockY(1);


		return new ColumnYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive);
	}

	public ThreeColumnYokelGameObject getRandomColumn() {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockClear();

		return new ThreeColumnYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive,getRngBlock(),getRngBlock(),getRngBlock());
	}
	
	public ThreeColumnYokelGameObject getThreeColumn(BlockType blockType1, BlockType blockType2, BlockType blockType3) {
		TextureRegion [] textureRegions = new TextureRegion[1];
		textureRegions[0] = imageProvider.getBlockClear();

		return new ThreeColumnYokelGameObject(imageProvider, textureRegions, soundManager,
				textureRegions[0].getRegionWidth(), textureRegions[0].getRegionHeight(),
				isHitboxActive,getBlock(blockType1),getBlock(blockType2),getBlock(blockType3));
	}

	public BlockYokelGameObject getRngBlock(){
		switch (MathUtils.random(0, 5)){
		case 0:
			return getYBlock();
		case 1:
			return getOBlock();	
		case 2:        	
			return getKBlock();
		case 3:        	
			return getEBlock();
		case 4:        	
			return getLBlock();
		case 5:        	
			return getBashBlock();
		default:
			return null;
		}
	}

	public BlockYokelGameObject getBlock(BlockType blockType){
		switch (blockType){
		case Y_BLOCK:
			return getYBlock();
		case O_BLOCK:
			return getOBlock();
		case K_BLOCK:        	
			return getKBlock();
		case E_BLOCK:        	
			return getEBlock();
		case L_BLOCK:        	
			return getLBlock();
		case BASH_BLOCK:        	
			return getBashBlock();
		case CLEAR_BLOCK:        	
			return getClearBlock();
		default:
			return null;
		}
	}

	public BrokenBlockYokelGameObject getBrokenBlock(BlockType blockType){
		switch (blockType){
		case Y_BLOCK:
			return getBrokenYBlock();
		case O_BLOCK:
			return getBrokenOBlock();
		case K_BLOCK:        	
			return getBrokenKBlock();
		case E_BLOCK:        	
			return getBrokenEBlock();
		case L_BLOCK:        	
			return getBrokenLBlock();
		case BASH_BLOCK:        	
			return getBrokenBashBlock();
		default:
			return null;
		}
	}
}
